package com.cc.flyingfish.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cc.flyingfish.entity.PointsEntity;
import com.cc.flyingfish.mapper.PointsMapper;
import com.cc.flyingfish.service.PointsService;
import com.cc.flyingfish.vo.CommonResponse;
import io.seata.core.context.RootContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author CHENCHEN
 * @since 2023-03-08
 */
@Slf4j
@Transactional(rollbackFor = Exception.class)
@Service
public class PointsServiceImp extends ServiceImpl<PointsMapper, PointsEntity> implements PointsService {

    @Override
    public CommonResponse insertPoints() {
        log.info("Seata全局事务id=================>{}", RootContext.getXID());
        this.save(new PointsEntity().setTotal(new BigDecimal("9")).setUserId(999L));
        throw new RuntimeException();
    }
}
